<?php

namespace App\Http;

use Illuminate\Routing\Router;
use Illuminate\Contracts\Foundation\Application;

use Illuminate\Foundation\Http\Kernel as HttpKernel;
use Illuminate\Support\Facades\Request;

class Kernel extends HttpKernel
{

    public function __construct(Application $app, Router $router)
    {
        //发送session id 给客户端使用时,注意生成顺序问题,session()->getId(),最好使用 session()->regenerate(); 重新生成一个session
        if (isset($_SERVER['HTTP_TOKEN'])) {  //如果是客户端 请求
            $_COOKIE['wedo_session'] = 'f6bffb5cefe3792e122e02d47b61dc8cb1339fb5';  //$_REQUEST['token']  or   $_SERVER['HTTP_TOKEN']
            unset($this->middleware[\App\Http\Middleware\EncryptCookies::class]);
        }


        parent::__construct($app, $router);
    }

    /**
     * The application's global HTTP middleware stack.
     *
     * @var array
     */
    protected $middleware = [
        \Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode::class,
        \App\Http\Middleware\EncryptCookies::class,
        \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
        \Illuminate\Session\Middleware\StartSession::class,
        \Illuminate\View\Middleware\ShareErrorsFromSession::class,
//        \App\Http\Middleware\VerifyCsrfToken::class,  //csrf验证
        \App\Http\Middleware\AfterRequestRecord::class,  //记录请求过程的相关数据

    ];

    /**
     * The application's route middleware.
     *
     * @var array
     */
    protected $routeMiddleware = [
        'AdminAuth' => \App\Http\Middleware\AdminAuth::class,
        'weixin_auth' => \App\Http\Middleware\WeiXinAuth::class,
        'no_auth' => \App\Http\Middleware\NoAuth::class,
        'play_jssdk' => \App\Http\Middleware\WeiXinJSSDK::class,
    ];
}
